const Service = require('egg').Service;

class MusicService extends Service{
    async list(pagenum,limit){
        //起始的下标  
        let startIndex = (pagenum-1)*limit;
        let list = await this.app.mysql.query(`select * from studentlist limit ${startIndex},${limit}`);
        return list
    }
    //添加
    async add(username,num,classNum,password,classRoom){
        await this.app.mysql.query('insert into studentlist (username,num,classNum,password,classRoom) values (?,?,?,?,?)',[username,num,classNum,password,classRoom])
    }
    //删除
    async del(id){
        await this.app.mysql.query('delete from studentlist where id=?',[id])
    }
    //更新
    async update(username,num,classNum,password,classRoom,id){
        await this.app.mysql.query('update studentlist set username=?,num=?,classNum=?,password=?,classRoom=? where id=?',[username,num,classNum,password,classRoom,id])
    }
}

module.exports = MusicService